package com.tgsoft.common.core.config;

import com.google.gson.*;
import com.google.gson.internal.LinkedTreeMap;
import com.google.gson.internal.bind.DateTypeAdapter;
import com.google.gson.internal.bind.ObjectTypeAdapter;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;




@Configuration
public class GosnConfiguration {

    @Bean
    public Gson getGson() {

        GsonBuilder builder = new GsonBuilder();
        builder.serializeNulls();
        builder.serializeSpecialFloatingPointValues();
        builder.registerTypeHierarchyAdapter(Date.class, new DateTypeAdapter());
        builder.setNumberToNumberStrategy(ToNumberPolicy.LONG_OR_DOUBLE);
        builder.setObjectToNumberStrategy(ToNumberPolicy.LONG_OR_DOUBLE);
        //builder.registerTypeAdapter(Number.class, new K3CloudObjectTypeAdapter());
        // 防止出现转义码
        //builder.disableHtmlEscaping();
        return builder.create();
        // 下面这个类路径 学习系统的转换
        //com.google.gson.internal.bind.ArrayTypeAdapter



        }




}



